import React, { Component } from 'react';
import './style.scss';
import { RouteComponentProps } from 'react-router-dom';

interface IProps extends RouteComponentProps {

}

class App extends Component<IProps> {
    handleRoutes = () => {
        const { location: { pathname }, history } = this.props;
        if (pathname === '/') {
            // 重定向到首页
            history.push('/index');
            return false;
        }
        return true;
    }

    render() {
        const { children } = this.props;
        return (
            <div className="container">
                {this.handleRoutes() && children}
            </div>
        );
    }
}

export default App;
